<template>
  <Fragment>
    <div class="head-wrap borderBottom-1px">
      <div class="title left borderBottom-2px">{{title}}</div>
      <div class="operate right"> <!---(item.id,curId)-->
        <span @click="changeTab(item.id)" v-for="(item,index) in items" :key="item.id" :class="{active : index===curId}">{{item.label}}</span>
      </div>
    </div>
    <div class="content-wrap">
      <div v-if="curId===0" class="chart-content" ref="reportSheetTrendStatistics1">
        2019
      </div>
      <div v-if="curId===1" class="chart-content" ref="reportSheetTrendStatistics2">
        2020
      </div>
    </div>
    <img src="@/assets/images/card819.png" class="card819" alt="">
  </Fragment>
</template>

<script>
import * as echarts from 'echarts';
import 'echarts-liquidfill'

import { Fragment } from 'vue-fragment'
export default {
  name:'box-card-multi-analysis2-baogaodanqushi',
  components:{Fragment},
  props:{
    items:{
      type:Array
    },
    title:{
      type:String
    }
  },
  data(){
    return{
      curId:0,
    }
  },
  mounted(){
    this.makeData()
  },
  methods:{
    changeTab(id){
      this.curId=id
    },
    makeData(){
       let label2 = ['周一','周二','周三','周四','周五','周六','周日']
      let data12 = [20, 52, 34, 91, 40, 30, 100]
    
      const option12 =  {
          tooltip : {
              trigger: 'axis'
          },
          calculable : true,
          xAxis : [
              {
                  type : 'category',
                  boundaryGap : false,
                  data : label2,
                  axisLabel: {
                      show: true,
                      textStyle: {
                          color: '#aaaaaa'
                      }
                  }
              }
          ],
          yAxis : [
              {
                  type : 'value',
                  interval:10,
                  splitLine: {
                    show: true,
                    lineStyle: {
                        color: '#233653'
                    },
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: "#233653"
                    }

                },
                axisLabel:{
                  textStyle:{
                    color:'#aaaaaa'
                  }
                }
              }
          ],
          grid: {
              top: '10%',
              left: '8%',
              right: '0%',
              bottom: '10%',
              // containLabel: true
          },
          series : [
            
              {
                  name:'预购',
                  type:'line',
                  smooth:true,
                  itemStyle: {normal: {areaStyle: {type: 'default',color:'#0A5730'},lineStyle: {color: '#625C0E'}}},
                  data:data12,
              }
            
          ]
      }

      this.makeGraph(this.$refs.reportSheetTrendStatistics1,option12)

      let data13 = [20, 52, 34, 91, 40, 30, 50]
      const option13 =  {
          tooltip : {
              trigger: 'axis'
          },
          calculable : true,
          xAxis : [
              {
                  type : 'category',
                  boundaryGap : false,
                  data : label2,
                  axisLabel: {
                      show: true,
                      textStyle: {
                          color: '#aaaaaa'
                      }
                  }
              }
          ],
          yAxis : [
              {
                  type : 'value',
                  interval:10,
                  splitLine: {
                    show: true,
                    lineStyle: {
                        color: '#233653'
                    },
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: "#233653"
                    }

                },
                axisLabel:{
                  textStyle:{
                    color:'#aaaaaa'
                  }
                }
              }
          ],
          grid: {
              top: '10%',
              left: '8%',
              right: '0%',
              bottom: '10%',
              // containLabel: true
          },
          series : [
            
              {
                  name:'预购',
                  type:'line',
                  smooth:true,
                  itemStyle: {normal: {areaStyle: {type: 'default',color:'#0A5730'},lineStyle: {color: '#625C0E'}}},
                  data:data13,
              }
            
          ]
      }
      this.makeGraph(this.$refs.reportSheetTrendStatistics2,option13) 
    },
    makeGraph(ref,option){
      let myChart=echarts.init(ref)
      myChart.setOption(option)
    }

  }
}
</script>
<style lang="less" scoped>
.left{float: left;}
.right{float: right;}
.borderBottom-1px{
  border-bottom: .01rem solid #7787C7 ;
}
.borderBottom-2px{
  border-bottom: .02rem solid #7787C7 ;
}
.head-wrap{
    font-size: .16rem;
    color:#ffffff;
    overflow: hidden;
    .title{
      height: .26rem;
      line-height: .262rem;
    }
    .operate{
      span{
        height: .26rem;
        line-height: .26rem;
        display: inline-block;
        cursor: pointer;
        background: url('~@/assets/images/671.png') no-repeat center center;
        background-size: contain;
        padding: 1px .2rem;
      }
      span.active{
        background: url('~@/assets/images/670.png') no-repeat center center;
        background-size: contain;
        padding: 1px .2rem;
      }
    }
  }
  .content-wrap{
    width: 100%;
    // height:calc( (100vh - 1.23rem) / 3 - .36rem) ;
    height:calc( (100vh - 1.23rem) * 4 / 10 - 0.36rem) !important;
    .chart-content{
      width: 100%;
      // height:calc( (100vh - 1.23rem) / 3 - .36rem) ;
      height:calc( (100vh - 1.23rem) * 4 / 10 - 0.36rem) !important;
      float: left;
      overflow: hidden;
    }
  }
  img{width: 100%;float: left;}
</style>